import logging
from redis import StrictRedis



class Config:
    SECRET_KEY ="iECgbYWReMNxkRprrzMo5KAQYnb2UeZ3bwvReTSt+V"
    SQLALCHEMY_DATABASE_URI = 'mysql://root:mysql@127.0.0.1:3306/xinwen'
    SQLALCHEMY_TRACK_MODIFICATIONS = False
    DEBUG = True
    # 设置这个配置,数据库会自动帮我们在响应结束后执行db.session.commit()操作
    SQLALCHEMY_COMMIT_ON_TEARDOWN = True

    REDIS_HOST = '127.0.0.1'
    REDIS_PORT = 6379
    # 配置session
    SESSION_TYPE = 'redis'
    # 设置加密
    SESSION_USE_SIGNER = True
    # 给session指定redis的端口号和ip地址
    SESSION_REDIS = StrictRedis(port=REDIS_PORT,host=REDIS_HOST)
    # 先设置过期,再设置过期时间
    SESSION_PERMANENT =  False
    PERMANENT_SESSION_LIFETIME = 86400*2
    LOG_LEVEL = logging.DEBUG

class DevelopmentConfig(Config):
    # 开发环境下,调试
    DEBUG = True
    # LOG_LEVEL = logging.DEBUG


class ProductionConfig(Config):
    # 生产环境下的配置
    DEBUG = False



class TestingConfig(Config):
    # 单元测试环境下的配置
    DEBUG = True
    TESTING = True


config = {
    "Test":TestingConfig,
    'devel':DevelopmentConfig,
    'product':ProductionConfig
}